package nowcoder.huawei;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.*;

/**
 * @author wuguojian
 * @description
 * @date 2023/4/12 下午9:46
 * https://www.nowcoder.com/practice/995b8a548827494699dc38c3e2a54ee9
 * 需要注意异常处理
 **/
public class HJ90 {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner in = new Scanner(new FileReader("input/nowcoder_huawei/HJ90.txt"));
//        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String ip = in.nextLine();
            String[] ips = ip.split("\\.");
            boolean isRealIP = true;
            if(ips.length != 4){
                isRealIP = false;
            }
            if(isRealIP) {
                try {
                    for (String i : ips) {
                        int a = Integer.parseInt(i);
                        if (a > 255 || a < 0 || !String.valueOf(a).equals(i)) {
                            isRealIP = false;
                        }
                    }
                }catch (Exception e){
                    isRealIP = false;
                }
            }
            System.out.println(isRealIP ? "YES" : "NO");
        }
    }
}
